﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WHC.OrderWater.Commons;


namespace WHC.Hotel.UI
{
    public partial class FrmBackKTVOrder : BaseForm
    {
        public FrmBackKTVOrder()
        {
            InitializeComponent();
        }

        private void FrmBackOrder_Load(object sender, EventArgs e)
        {

        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.None;

            #region 检查退单数量
            if (this.txtBackCount.Text.Length == 0)
            {
                MessageUtil.ShowTips("请输入退单数量");
                this.txtBackCount.Focus();
                return;
            }

            try
            {
                int allowCount = Convert.ToInt32(this.lblAllowCount.Text);
                int backCount = Convert.ToInt32(this.txtBackCount.Text);
                if (backCount > allowCount)
                {
                    string message = string.Format("退单数量必须小于允许数量:{0}", allowCount);
                    MessageUtil.ShowTips(message);
                    this.txtBackCount.Focus();
                    return;
                }
                if (backCount <= 0)
                {
                    MessageUtil.ShowTips("退单数量必须大于0");
                    this.txtBackCount.Focus();
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageUtil.ShowError(ex.Message);
                return;
            } 
            #endregion

            this.DialogResult = DialogResult.OK;
        }

        private void txtReason_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                btnOK_Click(null, null);
            }
        }
    }
}
